package com.sojson.config.advice;

import java.util.Date;

import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;

import com.sojson.config.converter.DateConvertEditor;

/**
 * 控制器全局切面类
 * 
 * @author liu
 * @date 2021-09-07
 */
@ControllerAdvice
public class GlobalAdvice {

    /**
     * 日期格式化
     * 
     * @param binder
     */
    @InitBinder
    public void init(ServletRequestDataBinder binder) {
        // 日期格式转换
        binder.registerCustomEditor(Date.class, new DateConvertEditor());
    }

}